<template>
    <div>
      <p>图书名称：<input type="text" v-model="name"></p>
      <p>阅读量：<input type="number" v-model="read"></p>
      <p>评论量：<input type="number" v-model="commit"></p>
      <p>发行时间：<input type="text" v-model="time"></p>  
        <button @click="addbooks()">添加</button>
    </div>    
</template>

<script>
import axios from "axios"
export default {
    name:"addbooks",
    data() {
        return {
            name:"",
            read:"",
            commit:"",
            time:"",
        }
    },
    methods:{
        addbooks(){
            let formdata = new FormData()
            formdata.append("name",this.name)
            formdata.append("read",this.read)
            formdata.append("commit",this.commit)
            formdata.append("time",this.time)
            axios({
                url:"http://127.0.0.1:8000/app03/books/",
                method:"post",
                data:formdata
            }).then(res=>{
                console.log(res.data)
            })
        }
    }
}
</script>

<style>

</style>
